Liberty BASIC 4 provides many new features, and they will be discussed in upcoming newsletter articles. This month, the focus is on the ability enable or disable controls, or to show them and hide them.
ENABLE, DISABLE
These two commands cause a control to be enabled and active, or disabled and inactive. When a control is disabled it appears to be grayed-out and it cannot be activated by the user. Here is a picture illustrating controls that are active (enabled) and the same controls when they are disabled.

To enable or disable controls, begin the command with the ! character for all windows and controls that can accept new text strings, or the command will simply be displayed on the control.
Use this feature to disable controls when their functions are not available during program execution. For instance, a "SAVE" button can be disabled when the program begins and there is nothing yet to save. The button can be enabled when the situation changes as the program runs, and there is something to save.
In earlier versions of Liberty BASIC, it was possible to enable and disable controls with the EnableWindow API call. The native functions provided by LB4 are much easier to use.
Here is the demo provided in the Liberty BASIC 4 helpfile.
nomainwin
button #win.bttn, "Hello",[hello],UL,10,70
checkbox #win.cbox, "Goodbye",[quit],[quit],10,160,120,24
menu #win, "&Main","&Enable",[doEnable],_
"&Disable",[doDisable],"E&xit",[quit]
open "Enable and Disable" for window as #win
wait
[quit] close #win:end
[doEnable]
#win.bttn "!Enable"
#win.cbox "Enable"
wait
[doDisable]
#win.bttn "!Disable"
#win.cbox "Disable"
wait
[hello] wait
SHOW, HIDE
These two commands cause a control to be visible or hidden. Begin the command with the ! character for all windows and controls that can accept new text strings, or the command will simply be displayed on the control.
In versions of Liberty BASIC before version 4, controls could be hidden by using the "locate" command to locate them off screen. To show them, the "locate" command was again used to put them in the desired location. It was also possible to hide and show controls with the ShowWindow API call. It is much easier to show and hide controls with the new commands. Here is a demo program from the Liberty BASIC 4 helpfile.
nomainwin
button #win.bttn, "Hello",[hello],UL,10,70
checkbox #win.cbox, "Goodbye",[quit],[quit],10,160,120,24
menu #win, "&Main","&Show",[doShow],_
"&Hide",[doHide],"E&xit",[quit]
open "Show and Hide" for window as #win
wait
[quit] close #win:end
[doShow]
#win.bttn "!Show"
#win.cbox "Show"
wait
[doHide]
#win.bttn "!Hide"
#win.cbox "Hide"
wait
[hello] wait